#ifndef _RENDERER_H_
#define _RENDERER_H_

#include <memory>
#include <SERender/Entity/Drawable.h>
#include <SERender/Drive/Drive.h>
#include <SECore/Descriptor.h>
#include <SERender/Renderer/RenderPass/RenderPass.h>
#include <SERender/Renderer/RenderFeature/RenderFeature.h>
#include <SERender/Resourses/FrameBuffer.h>
#include <SERender/Renderer/RenderTask.h>
#include <vector>

namespace SEngine
{
    class Renderer 
        : public Descriptor<RenderFeature>
        , public Descriptor<RenderPass>
        , public AnyDescriptor
    {
    public:
        Renderer(std::unique_ptr<IDrive> && drive) : m_drive(std::move(drive)) {}
        virtual ~Renderer() = default;

        std::unique_ptr<IDrive> & GetDrive() { return m_drive; }

        void SetFrameBuffer(FrameBuffer & fbo) { m_fbo = fbo; }
        std::optional<std::reference_wrapper<FrameBuffer>> GetFrameBuffer() { return m_fbo; }

        void BeginFrame();
        void DrawFrame();
        void EndFrame(); 

        void DrawEntity(Drawable & entity);

        void UseFrameBuffer(FrameBuffer & fbo, std::function<void(void)> && fn);

        void AddTask(std::unique_ptr<RenderTask> && task) { m_tasks.emplace_back(std::move(task)); }

    protected:
        std::unique_ptr<IDrive> m_drive;
        std::optional<std::reference_wrapper<FrameBuffer>> m_fbo;
        std::vector<std::unique_ptr<RenderTask>> m_tasks;
    };
} // namespace SEngine



#endif